<!doctype html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>缤格</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/swiper.min.css"/>
    <link rel="stylesheet" type="text/css" href="../../script/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/binge.css"/>
    <script type="text/javascript" src="../../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../../script/layui/layui.all.js"></script>
    <script type="text/javascript" src="../../script/swiper.min.js"></script>
    <script type="text/javascript" src="../../script/mobile.js"></script>

    <script type="text/javascript">
        window['adaptive'].desinWidth = 750;
        window['adaptive'].baseFont = 28;
        window['adaptive'].maxWidth = 750;
        window['adaptive'].init();
    </script>
</head>

<body>


<div class="circle-head bg-cover" id="circleBg" style="background: url(); height: 2.9rem;">
    <div id="header">
        <!-- header -->
        <div class="header" style="margin-bottom: 0;">
            <div class="head-back">
                <a href="javascript:void(0);" tapmode onclick="comeBack()" class="back-btn-white"></a>
            </div>
            <div class="head-title">
                <h6 style="color: transparent" class="circleName"></h6>
            </div>
            <div class="head-action">
                <a href="javascript:void(0);" tapmode class="action-btn-white"></a>
            </div>
        </div>

        <!-- header end -->
    </div>

    <div class="department-rank">

        <div class="rank-info">
            <div class="rank-num" id="ranking">NO.1</div>
            <div class="info">
                <h6 id="infoName">体育部</h6>
                <div class="pf">
                    <div class="star" id="star"></div>
                    <div class="mark" id='mark'>4.0分</div>
                </div>
            </div>
        </div>

        <div class="toEvaluate" tapmode onclick="toEvaluate('../circle/department_evaluate')">去评星</div>
    </div>

</div>
<div class="circle-list-section" style="border-top:none;">
    <div class="comment-kinds" style="height: 1rem;">
        <h6 style="font-size: 0.3rem;color: #ff7777;"><b>全部评价</b><span id="num">(0)</span></h6>
        <div class="screen-btn" tapmode onclick="screen(this)">按热度</div>
    </div>
    <div class="comment-area">
        <div class="comment-list area">
            <ul id="commentHtml">

            </ul>
            <div class="comment-input">
                <div class="input-box">
                    <input type="text" id="inputContent" readonly data-pid="" placeholder="写评论...">
                    <!--<button class="send-btn" tapmode onclick="comment_add()">确定</button>-->
                </div>
                <div class="comment-count">
                    <div class="count-li collect" id="collect" tapmode onclick="collect(this)">0</div>
                    <div class="count-li love" id="love" tapmode onclick="clickFabulous('',7,'',event)">0</div>
                    <div class="count-li msg" id="msg" tapmode onclick="toAllList()">0</div>
                </div>
            </div>

            <div class="edit-model">
                <div class="edit-input">
                    <div class="message-flex">
                        <div class="message-box" id="message">
                            <div class="message" id="article" contenteditable="true"></div>
                        </div>
                        <div class="message-img" style="display: none;" id="msgImg">
                            <img src="" alt="">
                            <span class="delete dn" tapmode onclick="removePic(this,event)"></span>
                        </div>
                    </div>

                    <div class="But">
                        <div class="but-list">
                            <a href="javascript:void(0);" tapmode onclick="upload()" class="imgBut"></a>
                            <a href="javascript:void(0);" tapmode onclick="showVideo()" class="videoBut"></a>
                            <a href="javascript:void(0);" tapmode onclick="toAiteList()" class="aiTeBut"></a>
                        </div>
                        <span class="submit" tapmode onclick="comment_add()">确定</span>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>

<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe.(photosweep的背景)
         It's a separate element as animating opacity is faster than rgba().(这是一个单独的元素，因为设置不透明度动画比rgba快) -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden.(带溢出的幻灯片包装：隐藏。) -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides.(装滑块的容器。)
             PhotoSwipe keeps only 3 of them in the DOM to save memory.(photosweep只将其中的3个保存在DOM中以节省内存。)
             Don't modify these 3 pswp__item elements, data is added later on.(不要修改这3个pswp_uitem元素，稍后会添加数据。) -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed.(默认（photosweepui_Default）界面位于滑动区域顶部,可以更改。) -->
        <div class="pswp__ui pswp__ui--hidden">
            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>
                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
                <button class="pswp__button pswp__button--share" title="Share"></button>
                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- element will get class pswp__preloader--active when preloader is running(元素将获得pswp_u类预加载程序——在预加载程序运行时处于活动状态) -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip" tapmode="" onclick=""></div>
            </div>
            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)"></button>
            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)"></button>
            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>
        </div>
    </div>
</div>

</body>
</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>

<link rel="stylesheet" href="../../script/jqueryphotoSwiper/css/default-skin/default-skin.css">
<link rel="stylesheet" href="../../script/jqueryphotoSwiper/css/photoswipe.css">
<script src="../../script/jqueryphotoSwiper/js/photoswipe-ui-default.min.js"></script>
<script src="../../script/jqueryphotoSwiper/js/photoswipe.js"></script>
<script src="../../script/jqueryphotoSwiper/js/index.js"></script>
<script type="text/javascript">
    var circle_id = '';//圈子id
    var ranking = '';//当前排名
    var department_id = '';//社团id
    var type = 1;//类型：1时间排序 2热度排序
    var page = 1;
    var pullUp = false;
    var video_id = 0;
    var msgImg_id = 0;
    apiready = function () {
        $api.fixStatusBar($api.dom('#header'));
        api.setStatusBarStyle({
            style: 'light', //设置APP状态栏字体色
            color: 'rgba(255,255,255,0)', //设置APP状态栏背景色
        });
        //setFixStatusBar(); //设置状态栏
        keybackListener()
        department_id = api.pageParam.id;
        ranking = api.pageParam.ranking;
        // department_id = 3;
        // ranking = 1;

        $("#ranking").html('NO.'+ranking);

        getDetail()

        //发布活动返回监听刷新
        api.addEventListener({
            name: 'star'
        }, function (ret, err) {
            getDetail()
        });

        //上拉加载
        pullUpLoading(function () {
            if (pullUp == true) {
                getDetail()
            }
        });

        SystemCheckVersion()

        api.addEventListener({
            name: 'aite'
        }, function(ret, err) {
            console.log(JSON.stringify(ret.value));
            var mid = ret.value.id;
            var mname = ret.value.name;
            var mUrl = '../activity/person_index';
            var m_id = {member_id: mid}
            $("#article").append('<span style="display: inline; color: #ff7777;" onclick=\'commonUrl("'+mUrl+'",'+jsonChange(m_id)+')\'>@'+mname+'</span>　');
        });

    };


    function toAllList() {
        //type: 1新闻，2帖子，3活动贴，4赛事，5战况，6投票，7广场评星
        getAllList(7,department_id)
    }


    //二级评论获取评论目标
    var _input = $("#inputContent");
    var _editModel = $(".edit-model");
    var _article = $("#article");
    _input.click(function () {
        _editModel.show();
        var html = _article.html()
        _article.html('').focus();
    });

    function reply(id, name) {
        var pid = id;
        _input.attr('placeholder', '回复：' + name);
        _input.attr('data-pid', pid);
        _editModel.show();
        _article.focus();
        console.log(pid)
    }

    /*_article.blur(function () {
        if (_article.html() == '' || msgImg_id != 0) {
            _input.val('');
            _input.attr('placeholder', '写评论...');
            _input.attr('data-pid', '');
        }
    });*/


    //关闭评论框
    _editModel.on('click', function () {
        _input.val('');
        _input.attr('placeholder', '写评论...');
        _input.attr('data-pid', '');
        _editModel.hide()
    });
    //阻止事件冒泡 关闭评论框
    _editModel.on('click', '.edit-input', function (event) {
        event.stopPropagation()
        /*_article.focus();*/
    });

    //评论
    var addStatus = true;
    function comment_add() {
        var pid = '', type = 7;
        if (_input.attr('data-pid')) {
            pid = _input.attr('data-pid');
            type = 0;
        }
        var param = {
            token: $api.getStorage('token'),
            type: type,//类型：1新闻 2帖子 3活动 0回复 4赛事，5战况，6投票，7广场
            key_id: department_id,
            content: _article.html(),
            pid: pid,//当type为0的时候必须传入,二级回复，就是评论的id
            icon: msgImg_id,
            void_id: video_id,
        }
        if (!isDefine(param.content)&&!isDefine(param.icon)&&!isDefine(param.void_id)) {
            pop.notice('请发表你的评论内容');
            return false;
        }
        if(addStatus == false){
            return;
        }
        console.log(jsonChange(param));
        // return;
        pop.loading();
        getAjax(Interface.comment_add, param, function (res) {
            addStatus = false;

            _editModel.hide();
            _article.html('');
            _input.attr('placeholder', '写评论...');
            _input.attr('data-pid', '');

            $("#msgImg").siblings('img').attr('src','').removeAttr('data-id');
            $("#msgImg").hide();
            msgImg_id = 0;
            video_id = 0;

            pop.notice(res.msg)
            pop.close();
            setTimeout(function () {
                page = 1;
                getEvaluateDetail()
                addStatus = true;
            }, 1500)
        }, function (error) {
            pop.notice(error.msg)
            pop.close();
        })
        _article.blur();//失去焦点
    }


    //上传图片
    function upload() {
        uploadHeadPic(function (res) {
            var msgImg = $("#msgImg");
            msgImg.show();
            msgImg.find('img').attr({
                'src': ajaxUrl + res.path,
                'data-id': res.icon
            });
            msgImg_id = res.icon;
            msgImg.find('.delete').show();
            // icons.push(res.icon)
        })
    }

    //删除图片
    function removePic(that,event){
        event.stopPropagation();
        var msgImg = $("#msgImg");
        var _this = $(that);
        _this.siblings('img').attr('src','').removeAttr('data-id');
        _this.hide();
        msgImg.hide();
        msgImg_id = 0;
    }

    //视频上传
    function showVideo() {

        api.actionSheet({
            title: '上传视频',
            cancelTitle: '取消',
            buttons: ['拍摄','选择视频']
        }, function (ret, err) {
            if (ret) {
                getVideo(ret.buttonIndex);
            }
        });
    }

    function getVideo(sourceType) {
        if (sourceType == 2) { // 从相机中选择
            var ISphoen = api.systemType;
            var UIAlbumBrowser = api.require('UIAlbumBrowser');
            UIAlbumBrowser.open({
                max: 1,
                type: 'video',
                isOpenPreview: false,
                classify: false,
                styles: {
                    bg: '#fff',
                    mark: {
                        icon: '',
                        position: 'bottom_left',
                        size: 20
                    },
                    nav: {
                        bg: 'rgba(0,0,0,0.6)',
                        titleColor: '#fff',
                        titleSize: 18,
                        cancelColor: '#fff',
                        cancelSize: 16,
                        finishColor: '#fff',
                        finishSize: 16
                    }
                },
                rotation: true
            }, function (ret) {
                // alert(JSON.stringify(ret));
                if (ret.eventType == "cancel") {
                    pop.notice("取消了操作！")
                    return;
                }
                var dt = ret.list;

                api.showProgress({
                    title: '正在上传...',
                    modal: true
                });
                if (ret) {
                    if (ISphoen == "ios") {
                        // for (var i in dt) {

                        UIAlbumBrowser.transPath({
                            path: ret.list[0].path
                        }, function (ret, err) {
                            if (ret) {
                                // alert(JSON.stringify(ret));
                                console.log(ret.path)
                                var ListVideoSec = ret.path;
                                api.ajax({
                                    url: ajaxUrl + Interface.upload_file,
                                    method: 'post',
                                    data: {
                                        files: {
                                            'file': ret.path,
                                        }
                                    }
                                }, function (ret, err) {
                                    console.log(JSON.stringify(ret))
                                    if (ret) {

                                        if (ret.code == 200) {
                                            //arrimg.push(ret)
                                            api.hideProgress();
                                            addVideos(ret.icon, ajaxUrl + ret.path, ListVideoSec);
                                        } else {
                                            api.hideProgress();
                                            api.toast({
                                                msg: ret.msg,
                                                location: 'middle'
                                            });
                                        }
                                    } else {

                                        api.hideProgress();
                                        api.toast({
                                            msg: err.msg,
                                            location: 'middle'
                                        });
                                    }
                                });
                            }
                        });
                        // }
                    } else {
                        var ListVideoSec = ret.list[0].path;
                        // for (var i in dt) {
                        api.ajax({
                            url: ajaxUrl + Interface.upload_file,
                            method: 'post',
                            data: {
                                files: {
                                    'file': ret.list[0].path,
                                }
                            }
                        }, function (ret, err) {
                            console.log(JSON.stringify(ret))
                            if (ret) {

                                if (ret.code == 200) {
                                    //arrimg.push(ret)
                                    api.hideProgress();
                                    addVideos(ret.icon, ajaxUrl + ret.path, ListVideoSec);
                                } else {
                                    api.hideProgress();
                                    api.toast({
                                        msg: ret.msg,
                                        location: 'middle'
                                    });
                                }
                            } else {
                                api.hideProgress();
                                api.toast({
                                    msg: err.msg,
                                    location: 'middle'
                                });
                            }
                        });


                        // }
                    }
                }
            });

        } else if (sourceType == 1) {
            //拍摄视频
            api.getPicture({
                sourceType: 'camera',
                encodingType: 'png',
                mediaValue: 'video',
                allowEdit: false,
                videoQuality: 'high',
                destinationType: 'url',
                saveToPhotoAlbum: true
            }, function (ret, err) {
                var ISphoen = api.systemType;
                if (ISphoen == "ios") {
                    if (ret == '') {
                        return;
                    }
                } else {
                    if (ret.data == '') {
                        return;
                    }
                }
                if (ret) {

                    var imgSrc = ret.data;
                    if (imgSrc != "") {

                        //$api.attr(ele, 'src', imgSrc);
                    }
                    api.showProgress({
                        title: '正在上传...',
                        modal: true
                    });
                    // api.hideProgress();
                    var ele = $api.dom('#paishe');
                    api.ajax({
                        url: ajaxUrl + Interface.upload_file,
                        method: 'post',
                        data: {
                            files: {
                                'file': ret.data,
                            }
                        }
                    }, function (ret, err) {
                        //  alert(JSON.stringify(ret));
                        if (ret) {
                            if (ret.code == 200) {

                                api.hideProgress();
                                addVideos(ret.icon, ajaxUrl + ret.path, imgSrc);

                            } else {
                                api.hideProgress();
                                api.toast({
                                    msg: ret.msg,
                                    location: 'middle'
                                });
                            }
                        } else {

                            api.hideProgress();
                            api.toast({
                                msg: err.msg,
                                location: 'middle'
                            });
                        }
                    });


                }
            });
        }
    }

    function addVideos(id, videoPath, bdvideopath) {

        var videoScreenshots = api.require('videoScreenshots');
        var timestamp = new Date().getTime();
        videoScreenshots.screenshots({
            videoUrl: bdvideopath,//视频url
            time: 1,
            name: timestamp
        }, function (ret) {
            if (ret.status == true) {
                console.log(JSON.stringify(ret));
                video_id = id;//上传之后的视频id

                comment_add()
            }
        });
    }


    //去评星
    function toEvaluate(path) {

        var param = {id:department_id}
        commonUrl(path,param)
    }


    //获取圈子详情
    function getDetail() {
        var param = {
            token: $api.getStorage('token'),
            gc_id: department_id,
        }

        pop.loading();
        getAjax(Interface.gc_details_top, param, function (res) {
            console.log(jsonChange(res))
            var data = res.data;//广场详情
            $("#circleBg").css({background: 'url('+ ajaxUrl + data.back_path +')'})
            $("#infoName").html(data.title)
            $("#mark").html(data.aver_socre+'分');


            layui.use(['rate'], function(){
                var rate = layui.rate;
                //只读
                rate.render({
                    elem: $("#star"),
                    value: data.aver_socre,
                    readonly: true,
                    half: true //开启半星
                });

            });

            getEvaluateDetail()

            pullUp = true;
            pop.close();
        }, function (error) {

            pop.notice(error.msg);
            pop.close();

        })
    }

    //获取圈子详情
    function getEvaluateDetail() {
        var param = {
            token: $api.getStorage('token'),
            gc_id: department_id,
            type: type,//类型：1时间排序 2热度排序
            page: page,
        }

        pop.loading();
        getAjax(Interface.gc_details_lower, param, function (res) {
            console.log(jsonChange(res))
            var list = res.data.list;//广场详情
            var commentHtml = '';
            if(isDefine(list)){

                $.each(list,function(i,item){
                  var comment = item.comment;

                  //楼主的徽章列表
                  var badgeHtml = '';
                  if (isDefine(item.member.badge_path)) {
                      for (var y = 0; y < item.member.badge_path.length; y++) {
                          badgeHtml += '<dd class="icon"><img src="' + ajaxUrl + item.member.badge_path[y] + '" alt=""></dd>';
                      }
                  }
                  //楼主的回复总条数
                  var count = '';
                  if (item.comment_count > 2) {
                      var c_id = {"id": item.id, 'detail_id': vote_id};
                      count = '<a href="javascript:void(0);" class="reply-count" tapmode onclick=\'commonUrl("../activity/comment_detail",' + jsonChange(c_id) + ')\'>共' + item.count + '条回复 ></a>'
                  }
                  var fabulous = '';
                  if (item.fabulous_status == 2) {
                      fabulous = '<div class="fabulous " tapmode onclick=\'clickFabulous(1,4,"' + item.id + '",event)\'>' + item.fabulous_number + '</div>'
                  } else {
                      fabulous = '<div class="fabulous on" tapmode onclick=\'clickFabulous(2,4,"' + item.id + '",event)\'>' + item.fabulous_number + '</div>'
                  }

                  var m_id = '', mUrl = '';
                  var user_id = $api.getStorage('userInfo').id;
                  if (item.member.id == user_id) {
                      mUrl = '../member/member';
                  } else {
                      mUrl = '../activity/person_index';
                      m_id = {member_id: item.member.id}
                  }

                  var report = {type: 5, pid: item.id}
                  var content = '';
                  if(isDefine(item.content)){
                      content = item.content;
                  }else {
                      content = '';
                  }
                  var replyHtml = '';
                  if (isDefine(comment)) {

                        $.each(item.comment,function(z,ztem){
                            //一级回复列表
                            var reply_li = '';//回复列
                            var replyUser = '';//回复列的用户名称
                            var reply_badge = '';//回复列的用户徽章
                            if (isDefine(ztem.member_badge_path)) {
                                for (var bb = 0; bb < ztem.member_badge_path.length; bb++) {
                                    reply_badge += '<dd class="icon"><img src="' + ajaxUrl + ztem.member_badge_path[bb] + '" alt=""></dd>';
                                }
                            }

                            replyUser = '<div class="list-user-info"  tapmode onclick=\'reply(' + ztem.id + ',"' + ztem.member_name + '","' + ztem.id + '")\'>' +
                                        '     <p class="user-name" >' + ztem.member_name + '</p>' +
                                        '     <dl class="badge-list ml5">' + reply_badge + '</dl><span class="ml15 f20 c-999">' + ztem.date + '</span>' +
                                        '</div>';

                            var Rimg = '';
                            if(ztem.icon != 0){
                                Rimg = '<div class="imglist"><div class="photoSwiper"><div class="img-dv"><a href="'+ajaxUrl+ztem.icon_path +'" style="display: block; width: 100%"><img style="width: 100%" src="'+ajaxUrl+ztem.icon_path+'" alt=""></a></div></div></div>'
                            }
                            var Rtxt = '';
                            if(isDefine(ztem.content)){
                                Rtxt = '<p style="word-break: break-all;">'+ztem.content+'</p>';
                            }
                            var Rvideo = '';
                            if(isDefine(ztem.void_id) && ztem.void_id != 0){
                                Rvideo = '<p style="text-decoration: underline; color: #ff7777;" tapmode onclick=\'play("'+ajaxUrl+ztem.void_path+'")\'>点击播放视频</p>';
                            }

                            reply_li = ' <div class="list-reply-li">' + replyUser + '<div class="list-reply-detail">' + Rimg + Rtxt + Rvideo + '</div></div>';
                            replyHtml += '<div class="list-reply-ul">' + reply_li + '</div>';


                            var reply_ul = ztem.details;

                            $.each(reply_ul,function(aa,atem){
                                //二级回复列表
                                var reply_li2 = '';//回复列
                                var replyUser2 = '';//回复列的用户名称
                                var reply_badge2 = '';//回复列的用户徽章
                                if (isDefine(atem.member_badge_path)) {
                                    for (var cc = 0; cc < atem.member_badge_path.length; cc++) {
                                        reply_badge2 += '<dd class="icon"><img src="' + ajaxUrl + atem.member_badge_path[cc] + '" alt=""></dd>';
                                    }
                                }
                                replyUser2 = '<div class="list-user-info"  tapmode onclick=\'reply(' + atem.id + ',"' + atem.member_name + '","' + ztem.id + '")\'>' +
                                            '     <p class="user-name" >' + atem.member_name + '</p>' +
                                            '     <dl class="badge-list ml5">' + reply_badge2 + '</dl><span class="ml15 f20 c-999">' + atem.date + '</span>' +
                                            '</div>';

                                var Rimg1 = '';
                                if(atem.icon != 0){
                                    Rimg1 = '<div class="imglist"><div class="photoSwiper"><div class="img-dv"><a href="'+ajaxUrl+atem.icon_path +'" style="display: block; width: 100%"><img style="width: 100%" src="'+ajaxUrl+atem.icon_path+'" alt=""></a></div></div></div>'
                                }
                                var Rtxt1 = '';
                                if(isDefine(atem.content)){
                                    Rtxt1 = '<p style="word-break: break-all;">'+atem.content+'</p>';
                                }
                                var Rvideo1 = '';
                                if(isDefine(atem.void_id) && atem.void_id != 0){
                                    Rvideo1 = '<p style="text-decoration: underline; color: #ff7777;" tapmode onclick=\'play("'+ajaxUrl+atem.void_path+'")\'>点击播放视频</p>';
                                }

                                reply_li2 = ' <div class="list-reply-li">' + replyUser2 + '<div class="list-reply-detail">'+
                                            '<span>回复 <em class="c-primary">' + atem.p_name + '</em>：</span>' + Rtxt1 + Rimg1 + Rvideo1 + '</div></div>';


                                replyHtml += '<div class="list-reply-ul">' + reply_li2 + '</div>'


                              })

                        })


                  }
                    var commentImg = '';
                  if(isDefine(comment[i].icon)){
                      if(comment[i].icon != 0){
                          commentImg = '<div class="imglist"><div class="photoSwiper"><div class="img-dv"><a href="'+ajaxUrl+comment[i].icon_path +'" style="display: block; width: 100%"><img style="width: 100%" src="'+ajaxUrl+comment[i].icon_path+'" alt=""></a></div></div></div>'
                      }
                  }

                    var commentTxt = '';
                    if(isDefine(comment[i].content)){
                        commentTxt = '<p>'+comment[i].content+'</p>';
                    }
                    var commentVideo = '';
                    if(isDefine(comment[i].void_id) && comment[i].void_id != 0){
                        commentVideo = '<p style="text-decoration: underline; color: #ff7777;" tapmode onclick=\'play("'+ajaxUrl+comment[i].void_path+'")\'>点击播放视频</p>';
                    }

                  commentHtml += '<li>' +
                      '                    <div class="list-user-info" tapmode onclick=\'commonUrl("' + mUrl + '",' + jsonChange(m_id) + ')\'>' +
                      '                        <div class="list-flex-space">'+
                      '                            <div class="user-img bg-cover" style="background-image: url(' + ajaxUrl + item.member.icon_path + ');"></div>' +
                      '                            <div class="star-flex">'+
                      '                                <div class="user-name">' + item.member.name + '<dl class="badge-list ml5" tapmode onclick="toBadgePage(event)">' + badgeHtml + '</dl></div>'+
                      '                            <div style="display:flex; align-items: center;">'+
                      '                                <div class="eStar" data-num="'+item.aver_socre+'"></div>'+
                      '                                <span class="f24">'+item.aver_socre+'分</span>'+
                      '                            </div>' +
                      '                            </div>'+
                      '                        </div>' + fabulous +
                      '                    </div>' +
                      '                    <div class="list-detail">' +
                      '                        <div class="detail">' + ++ commentTxt + commentImg + commentVideo + '</div>' +
                      '                        <div class="list-reply">' + replyHtml + count + '</div>' +
                      '                        <div class="list-flex">' +
                      '                            <div class="list-time">' +
                      '                                <span>' + item.date + '</span>' +
                      '                                <a href="javascript:void(0);" tapmode onclick=\'reply("' + item.id + '","' + item.name + '")\' class="c-primary">回复</a>' +
                      '                            </div>' +
                      '                            <a href="javascript:void(0);" tapmode onclick=\'commonUrl("../member/jubao",' + jsonChange(report) + ')\' class="list-action"></a>' +
                      '                        </div>' +
                      '                    </div>' +
                      '                </li>';




                })
                console.log(commentHtml)

                if (page == 1) {
                    $("#commentHtml").html(commentHtml)
                } else {
                    $("#commentHtml").append(commentHtml)
                }
                initPhotoSwipeFromDOM('.imglist');
                layui.use(['rate'], function(){
                    var rate = layui.rate;
                    //只读

                    $(".eStar").each(function () {
                        var _this = $(this);
                        var _num = _this.attr('data-num');
                        rate.render({
                            elem: _this,
                            value: Number(_num),
                            readonly: true,
                            half: true //开启半星
                        });
                    });

                });
                page++;
                pullUp = true;
            } else {
                if (page == 1) {
                    $("#commentHtml").html(noData)
                } else {
                    $("#commentHtml").append('<p class="t-c f24 pt10 pb10" style="color: #ccc;">没有更多了</p>')
                }
            }


            pop.close();
        }, function (error) {

            pop.notice(error.msg);
            pop.close();

        })
    }
    layui.use(['rate'], function(){
        var rate = layui.rate;
        //只读

        $(".eStar").each(function () {
            var _this = $(this);
            var _num = _this.attr('data-num');
            rate.render({
                elem: _this,
                value: _num,
                readonly: true,
                half: true //开启半星
            });
        });

    });
    //排序
    function screen(that) {
        if ($(that).hasClass('on')) {
            $(that).removeClass('on').html('按热度');
            sort = 1;

        } else {
            $(that).addClass('on').html('按时间');
            sort = 2;
        }
        page = 1;
        getDetail()
    }

    //二级评论获取评论目标
    var _input = $("#inputContent");
    var _editModel = $(".edit-model");
    var _article = $("#article");
    _input.click(function () {
        _editModel.show();
        var html = _article.html()
        _article.html('').focus();
        _insertimg(html);
    });

    var evaluate_star_id = ''
    function reply(id, name, star_id) {
        var pid = id;
        evaluate_star_id = star_id;
        _input.attr('placeholder', '回复：' + name);
        _input.attr('data-pid', pid);
        _editModel.show();
        _article.focus();
    }

    _article.blur(function () {
        if (_article.html() == '') {
            _input.val('');
            _input.attr('placeholder', '写评论...');
            _input.attr('data-pid', '');
        }
    });

    //点击小图片，显示表情
    $(".bq").click(function (e) {
        $(".face").slideToggle(); //慢慢向下展开
        e.stopPropagation(); //阻止冒泡事件
        var html = _article.html()
        _article.html('').focus();
        _insertimg(html);
    });

    //在桌面任意地方点击，关闭表情框
    $('.edit-model').click(function () {
        _editModel.hide()
        $(".face").hide(); //慢慢向上收
        _article.blur();
    });
    //点击表情框 阻止事件冒泡
    _editModel.on('click', '.face,.face ul', function (event) {
        event.stopPropagation()
        _article.focus();
    });
    //关闭评论框
    _editModel.on('click', '.edit-model', function () {
        _editModel.hide()
    });
    //阻止事件冒泡 关闭评论框
    _editModel.on('click', '.edit-input', function (event) {
        event.stopPropagation()
        /*_article.focus();*/
        $(".face").hide(); //慢慢向上收
    });

    //点击小图标时，添加功能
    $(".face ul li img").click(function () {
        var simg = $(this).attr('src');
        var img = '<img src="'+simg+'"/>'
        console.log(simg)
        /*此处如果不是插入图片可这样：
        var img_url = "插入测试的文字";*/
        _insertimg(img);

        $("#message").scrollTop($("#message")[0].scrollHeight);
        // $(".face").hide(); //慢慢向上收
    });
    //评论
    function comment_add() {
        var pid = '', type = 0;
        if (_input.attr('data-pid')) {
            pid = _input.attr('data-pid');
            type = 0;
        }
        var param = {
            token: $api.getStorage('token'),
            type: type,//类型：1新闻 2帖子 3活动 4赛事 5战况 0回复 6投票  7广场
            key_id: evaluate_star_id,
            content: _article.html(),
            pid: pid,//当type为0的时候必须传入,二级回复，就是评论的id
        }
        console.log(jsonChange(param))
        return;
        if (!isDefine(param.content)) {
            pop.notice('请输入评论内容');
            return false;
        }
        pop.loading();
        getAjax(Interface.comment_add, param, function (res) {
            _editModel.hide();
            $(".face").slideUp(); //慢慢向上收
            _article.html('');
            _input.val('');
            _input.attr('placeholder', '写评论...');
            _input.attr('data-pid', '');
            pop.notice(res.msg)
            pop.close();
            setTimeout(function () {
                page = 1;
                getEvaluateDetail()
            }, 500)
        }, function (error) {
            pop.notice(error.msg)
            pop.close();
        })
        _article.blur();//失去焦点
    }

    //排序
    function screen(that) {
        var _this = $(that);
        if (_this.html() == '按热度') {
            $(".screen-btn").html('按时间')
            hot = 2;
        } else {
            $(".screen-btn").html('按热度');
            hot = 1;
        }
        page = 1;
        getEvaluateDetail();
    }

    function _insertimg(str) {

        var selection = window.getSelection ? window.getSelection() : document.selection;

        var range = selection.createRange ? selection.createRange() : selection.getRangeAt(0);

        if (!window.getSelection) {

            document.getElementById('article').focus();

            var selection = window.getSelection ? window.getSelection() : document.selection;

            var range = selection.createRange ? selection.createRange() : selection.getRangeAt(0);

            range.pasteHTML(str);

            range.collapse(false);

            range.select();

        } else {

            document.getElementById('article').focus();

            range.collapse(false);

            var hasR = range.createContextualFragment(str);

            var hasR_lastChild = hasR.lastChild;

            while (hasR_lastChild && hasR_lastChild.nodeName.toLowerCase() == "br" && hasR_lastChild.previousSibling &&
            hasR_lastChild.previousSibling.nodeName.toLowerCase() == "br") {

                var e = hasR_lastChild;

                hasR_lastChild = hasR_lastChild.previousSibling;

                hasR.removeChild(e)

            }

            range.insertNode(hasR);

            if (hasR_lastChild) {

                range.setEndAfter(hasR_lastChild);

                range.setStartAfter(hasR_lastChild)

            }

            selection.removeAllRanges();

            selection.addRange(range)

        }

    }


</script>
